<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <div id="app"></div>
    <div id="app1"></div>
    <div id="app2"></div>
    <script src="../js/babel.min.js"></script>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/prop-types.js"></script>
    <script type="text/babel">
      class Demo extends React.Component {
        handleSubmit = (event) => {
          // 阻止表单提交
          event.preventDefault();
          alert(this.username.value + "," + this.password.value);
        };
        render() {
          return (
            <form  onSubmit={this.handleSubmit}>
              用户名：
              <input ref={(c) => (this.username = c)} name="username" />
              <br />
              密码：
              <input ref={(c) => (this.password = c)} name="password" />
              <br />
              <button>Login</button>
            </form>
          );
        }
      }

      ReactDOM.render(<Demo />, document.getElementById("app"));
    </script>
  </body>
</html>
